<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>个人中心</title>
      <link rel="stylesheet" type="text/css" href="../../css/api.css" />
      <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    	<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
      <link rel="stylesheet" type="text/css" href="../../css/common.css" />
      <style>
          html, body {width: 100%;min-height: 100%;background: #F3EFEE;}
          .aui-active .aui-bar-tab-label{
            color: #f5a51c
          }
          .login {height:240px;background-image: -webkit-linear-gradient(0deg, #f5c674, #ed824c);/*background-image: url(../../image/personal_bkg.jpg);background-repeat: no-repeat; background-size: cover;*/position: relative;}
      	.login .personal_logo {width: 4rem;height: 4rem;border-radius: 50%;margin: 0 auto 9px;/*position: absolute; top: 60px; left: 20px;*/}
      		.login .userinfo {position: absolute; top: 60px;text-align: center; left: 0; right: 0;}
      		.login .userinfo .title {font-size: 0.8rem; color: #fff;}

      		/* 设置条目 */
      		.item {height: 3rem;line-height: 3rem;padding-left: 0.7rem;background-color: #fff;}
      		.item_ico {float: left;width: 2.3rem;padding: 0.7rem 0.7rem 0.7rem 0;}
      		.item_arrow {float: right;width: 1.5rem;padding: 1rem 0.7rem 1rem 0;}
      		.item span {font-size: 0.7rem;}
          [v-cloak] {
              display: none;
          }
        #tab1 .aui-active{
          color: #f23030;
          border-bottom: 2px solid #f23030;
        }
        .aui-list-item-middle{
          padding-left: 0.75rem;
        }
        .aui-radio:checked{
          background-color: #f23030;
          border: solid 1px #f23030;
        }

        .aui-toast-content{
          color: #fff;
        }
      </style>
  </head>
  <body>
<div id="app" style="box-sizing:border-box" v-cloak>
  <div class="aui-tab" id="tab1">
    <div class="aui-tab-item aui-active" @click="balanceComm">佣金</div>
    <div class="aui-tab-item" @click="bothCom(1)">市代</div>
    <div class="aui-tab-item" @click="bothCom(2)">区县代</div>
  </div>
  <div id="tab1-con">
      <div id="tab1-con1">
        <ul class="aui-list aui-media-list"  style="margin-top:10px;">
          <li><div class="user_nav_line"></div></li>
          <li class="aui-list-item-middle">
              <div class="aui-media-list-item-inner">
                  <div class="aui-list-item-inner">
                      <div class="aui-list-item-text">
                          <div class="aui-list-item-title aui-font-size-14" style="color:#f23030;">{{ totalRevenue==''?0:totalRevenue}}份收益</div>
                          <div class="aui-list-item-right order_wait_pay aui-font-size-14"  style="color:#f23030;">共{{allMount==''?0:allMount}}元</div>
                      </div>

                  </div>
              </div>
          </li>
          <li><div class="user_nav_line"></div></li>
           <li class="aui-list-item aui-list-item-middle" style="border-bottom:1px solid #eee;" v-for="value in listMsg">
               <div class="aui-media-list-item-inner">
                   <div class="aui-list-item-inner">
                       <div class="aui-list-item-text">
                           <div class="aui-list-item-title aui-font-size-14">
                              <div>{{value.way_name}}</div>
                              <div style="color:#999">{{value.posttime}} &nbsp;来源于：{{value.username}}</div>
                           </div>
                           <div class="aui-list-item-right order_wait_pay aui-font-size-16" >{{value.amount | amount}}</div>
                       </div>

                   </div>
               </div>
           </li>


      </ul>



    </div>
      <div id="tab1-con2" class="aui-hide">
        <ul class="aui-list aui-media-list"  style="margin-top:10px;">
          <li><div class="user_nav_line"></div></li>
          <li class="aui-list-item-middle">
              <div class="aui-media-list-item-inner">
                  <div class="aui-list-item-inner">
                      <div class="aui-list-item-text">
                          <div class="aui-list-item-title aui-font-size-14" style="color:#f23030;">{{totalRevenue==''?0:totalRevenue}}份收益</div>
                          <div class="aui-list-item-right order_wait_pay aui-font-size-14"  style="color:#f23030;">共{{allMount==''?0:allMount}}元</div>
                      </div>

                  </div>
              </div>
          </li>
          <li><div class="user_nav_line"></div></li>
           <li class="aui-list-item aui-list-item-middle" style="border-bottom:1px solid #eee;" v-for="value in listMsg">
               <div class="aui-media-list-item-inner">
                   <div class="aui-list-item-inner">
                       <div class="aui-list-item-text">
                           <div class="aui-list-item-title aui-font-size-14">
                              <div>{{value.way_name}}</div>
                              <div style="color:#999">{{value.posttime}} &nbsp;来源于：{{value.username}}</div>
                           </div>
                           <div class="aui-list-item-right order_wait_pay aui-font-size-16" >{{value.amount | amount}}</div>
                       </div>

                   </div>
               </div>
           </li>


      </ul>

      </div>
      <div id="tab1-con3" class="aui-hide">
        <ul class="aui-list aui-media-list"  style="margin-top:10px;">
          <li><div class="user_nav_line"></div></li>
          <li class="aui-list-item-middle">
              <div class="aui-media-list-item-inner">
                  <div class="aui-list-item-inner">
                      <div class="aui-list-item-text">
                          <div class="aui-list-item-title aui-font-size-14" style="color:#f23030;">{{totalRevenue==''?0:totalRevenue}}份收益</div>
                          <div class="aui-list-item-right order_wait_pay aui-font-size-14"  style="color:#f23030;">共{{allMount==''?0:allMount}}元</div>
                      </div>

                  </div>
              </div>
          </li>
          <li><div class="user_nav_line"></div></li>
           <li class="aui-list-item aui-list-item-middle" style="border-bottom:1px solid #eee;" v-for="value in listMsg">
               <div class="aui-media-list-item-inner">
                   <div class="aui-list-item-inner">
                       <div class="aui-list-item-text">
                           <div class="aui-list-item-title aui-font-size-14">
                              <div>{{value.way_name}}</div>
                              <div style="color:#999">{{value.posttime}} &nbsp;来源于：{{value.username}}</div>
                           </div>
                           <div class="aui-list-item-right order_wait_pay aui-font-size-16" >{{value.amount | amount}}</div>
                       </div>

                   </div>
               </div>
           </li>


      </ul>
      </div>

  </div>
</div>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/zepto.js"></script>
  <script type="text/javascript" src="../../script/vue.min.js"></script>
  <script type="text/javascript" src="../../script/utils.js"></script>
  <script type="text/javascript" src="../../script/common.js"></script>
  <script type="text/javascript" src="../../script/aui-tab.js"></script>
  <script type="text/javascript" src="../../script/aui-scroll.js"></script>
  <script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
  <script type="text/javascript" src="../../script/aui-toast.js"></script>
  <script type="text/javascript">
      apiready = function(){
        // api.parseTapmode();
        var toast = new auiToast({});
        new Vue({
          el:'#app',
          data:{
            listMsg:[],
            allMount:'',
            totalRevenue:''
          },
          methods:{
            //佣金
              balanceComm:function(){
                var _this = this;
                _this.allMount = '';
                _this.totalRevenue ='';
                _this.listMsg = [];
                api.ajax({
                    url: window.Url.Freeucenter_balanceCommission,
                    method: 'post',
                    data: {
                        values: {
                            token:$api.getStorage('token'),
                            page:1
                        }
                    }
                },function(ret, err){
                    if (ret.re==1) {
                      _this.allMount = ret.data.commission;
                      _this.totalRevenue = ret.data.count;
                      _this.listMsg = ret.data.list;
                    } else {
                      toast.fail({
                        title:ret.info,
                        duration:1000
                      })

                    }
                });

              },
              //市代/区代
              bothCom:function(type){
                var _this = this;
                _this.allMount = '';
                _this.totalRevenue ='';
                _this.listMsg = [];
                api.ajax({
                    url: window.Url.Freeucenter_balanceAgent,
                    method: 'post',
                    data: {
                        values: {
                            token:$api.getStorage('token'),
                            type:type,
                            page:1
                        }

                    }
                },function(ret, err){
                    if (ret.re == 1) {
                      _this.allMount = ret.data.commission;
                      _this.totalRevenue = ret.data.count;
                      _this.listMsg = ret.data.list;
                    } else {
                        // alert( JSON.stringify( err ) );
                        toast.fail({
                          title:ret.info,
                          duration:1000
                        })
                    }
                });

              },
              //刷新
              setRefresh:function() {
                  var pullRefresh = new auiPullToRefresh({
                      container: document.querySelector('.aui-refresh-content'),
                      triggerDistance: 100
                  }, function(ret) {

                      if (ret.status == "success") {
                          setTimeout(function() {
                              pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                          }, 1500)
                      }
                  })
              }
          },
          mounted:function(){

            this.balanceComm();
            var tab = new auiTab({
              element:document.getElementById("tab1")
            },function(ret){
              if(ret){
                  //  定义获取对象的所有兄弟节点函数
                  function siblings(elm) {
                      var a = [];
                      var p = elm.parentNode.children;
                      for(var i =0,pl= p.length;i<pl;i++) {
                      if(p[i] !== elm) a.push(p[i]);
                      }
                      return a;
                  };
                  var index = ret.index;
                  var activeC = document.getElementById("tab1-con" + index);
                  activeC.className = "";
                  for(var i=0;i<siblings(activeC).length;i++){
                      siblings(activeC)[i].className = "aui-hide";
                  }
              }
          });
        },
        filters:{
          amount(value){
            return  '￥'+Base64.decode(value).slice(3,-5)
          }
         }
        })

      };


  </script>
  </html>
